﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using 路由事件.Tools;
using 路由事件.View;

namespace 路由事件
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }


        private void Window_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Window对象的隧道事件PreviewMouseUp被触发");
        }

        private void Border_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Border对象的隧道事件PreviewMouseUp被触发");

        }

        private void Canvas_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Canvas对象的隧道事件PreviewMouseUp被触发");

        }

        private void Button_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Button确定按钮的隧道事件PreviewMouseUp被触发");

        }

        private void Button_PreviewMouseUp_1(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Button取消按钮的隧道事件PreviewMouseUp被触发");

        }


        private void Window_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Window对象的冒泡事件MouseUp被触发");
        }

        private void Border_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Border对象的冒泡事件MouseUp被触发");
        }
        private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Canvas对象的冒泡事件MouseUp被触发");
        }

        private void Button_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Button1的冒泡事件MouseUp被触发");
        }


        private void Button_MouseUp_1(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine($"Button2的冒泡事件MouseUp被触发");
        }


        private void Widget_Completed(object sender, RoutedEventArgs e)
        {
            Widget widget = sender as Widget;
            listBox.Items.Insert(0, $"完成目标销售额：{widget.Value}");
        }


     

        private void Widget_Check(object sender, RoutedEventArgs e)
        {
            Widget widget = sender as Widget;
            if (((int)widget.Value) % 500000 < 5000)
            {
                listBox.Items.Insert(0, $"当前业绩：{widget.Value}，每累计50万发奖金啦：{widget.Value * 0.5}");
            }
        }

        private void Widget_Check2(object sender, RoutedEventArgs e)
        {
            Widget widget = sender as Widget;
            listBox.Items.Insert(0, $"完成目标销售额：{widget.Value}");
            widget.RaiseEvent(new RoutedEventArgs(SalesManager.CheckEvent));
        }
    }
}